﻿package com.javaPattern.State;

import java.util.*;

public class Context {
	// 保持各种工具的列表
	Map<String, State> toolBar = new HashMap<String, State>();
	
	State toolState;
	
	public void addState(String name,State state){
		toolBar.put(name, state);
	}
	
	// 改变状态
	public void selectState(String name){
		toolState = toolBar.get(name);
	}
	
	// 执行具体的动作
	public void action(){
		toolState.draw();
	}
}
